import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-07-03
 * Time: 13:23
 */
public class Test11 {

    public static int[] maxWindow(int[] num, int k) {
        Deque<Integer> dq = new LinkedList<>();
        int n = num.length;
        int[] ret = new int[n-k+1];
        for(int i = 0; i < n; i++) {
            // 出窗口
            if(!dq.isEmpty() && dq.peekFirst() == i-k) {
                dq.pollFirst();
            }
            //比较大小
            while(!dq.isEmpty() && num[dq.peekLast()] <= num[i]) {
                dq.pollLast();
            }
            dq.offerLast(i);
            if(i >= k-1) {
                ret[i-k+1] = num[dq.peekFirst()];
            }
        }
        return ret;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num = new int[n];
        for(int i = 0; i < n;i++) {
            num[i]  = sc.nextInt();
        }
        int k = sc.nextInt();
        int[] ret = maxWindow(num,k);
        System.out.println("滑动窗口最大值："+ Arrays.toString(ret));
    }
}

